feat(keymap)!: replace expr keymaps with normalized feedkeys execution #2266
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
|
Does calling |
|
Thanks for the feedback, you give me some additional thinking! I'd like to explore this approach a bit more. The Edit: Updated PR description |
|
Wow this is quite a bit of work, you'd end up fixing all the major issues with keymaps! These changes would be breaking, since theyre no longer Fyi, I got a bit ambitious with v2 so I'm going to reduce its scope. Just planning some light refactoring, these keymap changes, source-per-LSP, adopt blink.lib, and the improved API (for keymaps, enable, vim.g, dynamic config, etc) |
|
Yeah, as long as I'm here, I might as well fix these issues once and for all. I've had promising results locally. I don't mind working on this for v2, but last time I switched to this branch, everything was so broken that it was hard to make any convincing commits. Feel free to keep in touch on Matrix to coordinate! |
fec6db0 to
c855892
Compare
c855892 to
d080c78
Compare
d080c78 to
530299a
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
c3a2351 to
b784f83
Compare
saghen
left a comment
There was a problem hiding this comment.
This is some brilliant work, thank you so much! Going to start daily driving this
83c8837 to
f4ec48f
Compare
|
Lmk if you're happy with it and I'll merge it after the next release (release after 1.10 will be 2.0) |
f4ec48f to
e42586f
Compare
Yes, this seems stable enough! Note I was initially hesitant about 2bf5cf8 due to your comment, so I focused only on the keymap module. This commit closes #2333, #2381 ( Before merging, we need to:
Overall, I'm super excited to see this on your radar and see it land! |
This change introduces: - multi-key sequence support (e.g. `<C-x><C-o>`) - normalized key comparison and equivalence (`<C-i>` == `<Tab>`) - key composition from user callbacks - fallback handling, including `<Plug>`, `<SID>`, and script mappings - automatic reapplication of missing (stolen) buffer keymaps Keymaps are now buffer-local for all modes, rely on normalized key notation instead of termcodes, and execute commands eagerly until one succeeds. BREAKING CHANGE: Keymap execution semantics, fallback behavior, and mapping scope have changed. expr mappings are no longer used.
Script-function tokens were parsed using keycode grammar
dadb6a1 to
288a776
Compare
Also move `can_select` check into `completion.list.select_next/prev` so the selection functions are self-contained.
Yeah I initially wanted to wait for v2, but I'm about to make the 1.10 release and next will be 2.0, so we can begin making breaking changes |
|
Excellent, I was worried things were getting too stable! |
|
Gotta give the people something to tinker with in their config 😂 |
|
Merging without the documentation changes because I want to start the bigger refactors, but don't want to cause tons of merge conflicts for ya. Can't say it enough, brilliant work on this |
Revamped the keymap documentation to align with recent API changes introduced in #2266.
Revamped the keymap documentation to align with recent API changes introduced in #2266. --------- Co-authored-by: Liam Dyer <liamcdyer@gmail.com>
Revamp keymap handling by moving away from expr mappings to a normalized feedkeys approach, fixing several long-standing edge cases around multi-key mappings, fallbacks, and interoperability with other plugins.
{ ['jk'] = { 'hide', 'fallback' }, ['<C-x><C-o>'] = { 'show', 'fallback' }, ['<Leader>cc'] = { 'show', 'fallback' }, }{ ['<C-n>'] = { 'select_next' }, ['<Tab>'] = { function() return '' end, -- would fallback function() return '<C-n>' end, -- would call `select_next` }, },<SNR>,<SID>,<Plug>keymapmodule as simply as possibleexpr,vim.schedulein all commands and return boolean value from the function itselfCloses #406
Closes #453
Closes #714
Closes #1879
Closes #2119
Closes #2164
Closes #2182
Closes #2263
Closes #2333
Closes #2384